﻿@using KRM.Core
@model KRM.Core.tblKRWProductReview
@using KRM.Core.DataObject
@{
    ViewBag.Title = Model.reviewID > 0 ? "Edit Review" : "Add New Review";
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
    <script src="~/js/product.js"></script>
    var _db = (KRMEntities)ViewBag.db;

    var user = (tblUser)ViewBag.user;
    var disable = user.HasPermission(Permissions.CanViewModerateReviews);
    var disabled = disable ? "disabled" : "";
}
<form method="POST" id="frm-Review" action="/products/Review">
    <div style="padding: 5px 10px">
        <div class="fieldset">
            <div class="legend">Feedback Details</div>
            <div class="row-fluid">
                <div class="span2">Website</div>
                <div class="span4">
                    <input type="hidden" name="reviewid" value="@Model.reviewID" />
                    @Html.DropDownList("Stores", null, "None", new { @class = "input-block-level", @required = "Requied", onchange = "reviewstorechange(this.value)", @disabled })
                </div>
                <div class="span2 text-right">Product</div>
                <div class="span4">
                    @Html.DropDownList("Products", null, "None", new { @class = " Products input-block-level", @required = "Requied", @disabled })

                </div>
            </div>
            <div class="row-fluid">
                <div class="span2">Date Placed</div>
                <div class="span4">
                    <input type="text" name="datePlaced" @(disable ? "disabled=disabled" : "")  readonly="readonly" class="input-block-level" value="@Model.datePlaced" />
                </div>
                <div class="span2 text-right">Email</div>
                <div class="span4">
                    <input type="text"  name="email"  value="@Model.email" class="email input-block-level" @(disable ? "disabled=disabled" : "") />
                </div>
            </div>

            <div class="row-fluid">
                <div class="span2">Reviewer Name</div>
                <div class="span4">
                    <input type="text" name="reviewerName" class="input-block-level" value="@Model.reviewerName"  @(disable ? "disabled=disabled" : "") />
                </div>
                <div class="span2 text-right">Rating(1-5)</div>
                <div class="span4">
                    <input type="text" name="rating" @(disable ? "disabled=disabled" : "") value="@Model.rating" class="input-block-level" />
                </div>
            </div>
            <div class="row-fluid">
                Review
            <div class="span12">
                <textarea class="input-block-level" name="review"  @(disable ? "disabled=disabled" : "")>@Model.review</textarea>
            </div>
            </div>
        </div>
        <div class="fieldset">
            <div class="legend">Action</div>
            <div class="row-fluid">
                <div class="span2">Moderated By</div>
                <div class="span4">
                    @{
                        user = _db.tblUsers.Find(Model.moderatedBy);
                    }
                    <input type="text" @(disable ? "disabled=disabled" : "") name="moderatedBy" readonly="readonly" class="input-block-level" value="@(user != null ? user.Username : "Not Approved Yet")" />
                </div>
                <div class="span2 text-right">Moderated Date</div>
                <div class="span4">
                    <input type="text" @(disable ? "disabled=disabled" : "") name="dateChanged" readonly="readonly" value="@Model.dateChanged" class="input-block-level" />
                </div>
            </div>
        </div>
        <div class="row-fluid">
            Internal Comment
        <div class="span12">
            <textarea class="input-block-level" @(disable ? "disabled=disabled" : "") name="privateComment">@Model.privateComment</textarea>
        </div>
        </div>
        <div class="row-fluid">
            <div class="span4" @(disable ? "disabled=disabled" : "") >@Html.Action("ReviewReasons", "Products")</div>
            <div class="span4 blockui" @(disable ? "disabled=disabled" : "")>
                <input type="button" @(disable ? "disabled=disabled" : "") name="" value="Find Related Order(s)" onclick="FindRelatedOrder()" class="btn btn-primary" />
                <div class="order-collection" style="overflow: scroll; overflow-x: hidden; height: 180px">
                    @Html.Action("OrderCollections", "Products")
                </div>
            </div>
            <div class="span4">
                <b>Tasks to be Created</b>
                <div class="row-fluid">
                    <div class="span6">
                        <label>
                            <input type="checkbox" name="TasksToBeCreated" class="cbcheck TasksToBeCreated" value="0" />
                            CERT Task</label>
                    </div>
                    <div class="span6">
                        <label>
                            <input type="checkbox" name="TasksToBeCreated" class="cbcheck TasksToBeCreated" value="1" />CRF Task</label>
                    </div>
                </div>

                <div class="span12">
                    <b>Review Status</b>
                    @foreach (var item in (List<ComboboxStringID>)ViewBag.ReviewStatus)
                    {
                        if (item.Select == item.Id || item.Id == "NotModerated")
                        { <label>@Html.RadioButton("ReviewStatus", item.Id, new { @checked = "checked", @class = " cbcheck", @disable })@item.Name</label>
                        }
                        else
                        {
                        <label>@Html.RadioButton("ReviewStatus", item.Id, new { @class = " cbcheck", @disable })@item.Name</label>
                        }
                    }
                </div>
                <div class="row-fluid">
                    <div class="span12 text-left">
                        @if (!disable)
                        {
                            <input type="submit" value="Save" class="btn btn-success" style="padding: 5px 40px;" />
                        }
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
